package com.cans.ws.impl;

import com.cans.model.User;
import com.cans.ws.api.IUserService;

import javax.jws.WebService;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: cans
 * @date: 2017/11/16
 * @description:
 */
@WebService(targetNamespace="http://api.ws.cans.com/",endpointInterface = "com.cans.ws.api.IUserService")
public class UserServiceImpl implements IUserService {

    private Map<Long, User> userMap = new HashMap<>();

    public UserServiceImpl() {
        User user = new User();
        user.setUserId(10001L);
        user.setUsername("cans");
        user.setEmail("cans@163.com");
        user.setGmtCreate(new Date());
        userMap.put(user.getUserId(), user);

        user = new User();
        user.setUserId(10002L);
        user.setUsername("jun");
        user.setEmail("jun@163.com");
        user.setGmtCreate(new Date());
        userMap.put(user.getUserId(), user);

        user = new User();
        user.setUserId(10003L);
        user.setUsername("zuo");
        user.setEmail("zuo@163.com");
        user.setGmtCreate(new Date());
        userMap.put(user.getUserId(), user);
    }

    @Override
    public String getName(Long userId) {
        return "cans-" + userId;
    }
    @Override
    public User getUser(Long userId) {
        return userMap.get(userId);
    }
}
